home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer: Getting Started / Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin / pc / mac / bonus / peter_le / dehqx-20 / calccrc.a < prev    next >
Text File  |  1991-08-23  |  1KB  |  68 lines

  1. ; DeHQX v2.0.0 ⌐ Peter Lewis, Aug 1991
  2.  
  3.     macro
  4.     PUSH
  5.     move.l    &SYSLIST[1],-(sp)
  6.     endm
  7.         
  8.     macro
  9.     POP
  10.     move.l    (sp)+,&SYSLIST[1]
  11.     endm
  12.  
  13. regspc    equ        16
  14. rtsoff    equ        regspc+0
  15. voff    equ        regspc+4
  16. crcoff    equ        regspc+6
  17.  
  18. proc    Main
  19.     export    CalcCRC
  20. ; procedure CalcCRC(var crc:integer; v:integer);
  21. ; @crc        @a0 = d0
  22. ; v            d1
  23. ; @rts
  24. CalcCRC
  25.     MOVEM.L    A0/D0-D2,-(SP)    ;Save all regs. except D0
  26.  
  27.     move.l    crcoff(sp),a0
  28.     move.w    (a0),d0
  29.     move.w    voff(sp),d1
  30.     
  31.     move.w    #7,d2
  32. loop
  33.     lsl.b    #1,d1
  34.     roxl.w    #1,d0
  35.     bcc        noxor
  36.     eor.w    #$1021,d0
  37. noxor
  38.     dbf        d2,loop
  39.     
  40.     move.w    d0,(a0)
  41.     
  42.     MOVEM.L    (SP)+,A0/D0-D2
  43.     move.l    (sp),6(sp)
  44.     add.l    #6,sp
  45.     RTS
  46.  
  47.     END
  48.     
  49. procedure CalcCRC (v: integer);
  50.     var
  51.         temp: boolean;
  52.         i: integer;
  53. begin
  54.     for i := 1 to 8 do begin
  55.         temp := BAND(crc, $8000) <> 0;
  56.         crc := BOR(BSL(crc, 1), BSR(v, 7));
  57.         if temp then
  58.             crc := BXOR(crc, $1021);
  59.         v := BAND(BSL(v, 1), $FF);
  60.     end;
  61. end;
  62.  
  63. asm -wb "{active}"
  64. (evaluate "{active}" =~ /(?*):(?*)¿1.a/ )> dev:null
  65. (evaluate "{active}" =~ "/(?*)¿2.a/" )> dev:null
  66. link -sn CalcCRC="{¿1}" "{active}.o" -o "{¿2}"
  67. dumpcode "{¿2}"
  68.